#include "Model.h"

#pragma comment(lib, "opengl32.lib")
#pragma comment(lib, "glu32.lib")
#include <windows.h> // Header File For Windows
#include <gl\gl.h> // Header File For The OpenGL32 Library
#include <gl\glu.h> // Header File For The GLu32 Library

#include <stdio.h>

CModel::CModel(void)
{
	vTopLeft.Set( 1.0f, 1.0f, 1.0f );
	vBottomRight.Set( -1.0f, -1.0f, -1.0f );
	red = 128;
	green = 255;
	blue = 0;
}

CModel::~CModel(void)
{
}

void CModel::Draw(void)
{
	glPushMatrix();

	glColor3f(red, green, blue);
	glBegin(GL_QUADS);

	/*      This is the top face*/
	glVertex3f(vTopLeft.x, vTopLeft.y, vTopLeft.z);
	glVertex3f(vTopLeft.x, vTopLeft.y, vBottomRight.z);
	glVertex3f(vBottomRight.x, vTopLeft.y, vBottomRight.z);
	glVertex3f(vBottomRight.x, vTopLeft.y, vTopLeft.z);

	/*      This is the front face*/
	glVertex3f(vTopLeft.x, vTopLeft.y, vTopLeft.z);
	glVertex3f(vBottomRight.x, vTopLeft.y, vTopLeft.z);
	glVertex3f(vBottomRight.x, vBottomRight.y, vTopLeft.z);
	glVertex3f(vTopLeft.x, vBottomRight.y, vTopLeft.z);


	/*      This is the right face*/
	glVertex3f(vTopLeft.x, vTopLeft.y, vTopLeft.z);
	glVertex3f(vTopLeft.x, vBottomRight.y, vTopLeft.z);
	glVertex3f(vTopLeft.x, vBottomRight.y, vBottomRight.z);
	glVertex3f(vTopLeft.x, vTopLeft.y, vBottomRight.z);

	/*      This is the left face*/
	glVertex3f(vBottomRight.x, vTopLeft.y, vTopLeft.z);
	glVertex3f(vBottomRight.x, vTopLeft.y, vBottomRight.z);
	glVertex3f(vBottomRight.x, vBottomRight.y, vBottomRight.z);
	glVertex3f(vBottomRight.x, vBottomRight.y, vTopLeft.z);

	/*      This is the bottom face*/
	glVertex3f(vTopLeft.x, vBottomRight.y, vTopLeft.z);
	glVertex3f(vTopLeft.x, vBottomRight.y, vBottomRight.z);
	glVertex3f(vBottomRight.x, vBottomRight.y, vBottomRight.z);
	glVertex3f(vBottomRight.x, vBottomRight.y, vTopLeft.z);

	/*      This is the back face*/
	glVertex3f(vTopLeft.x, vTopLeft.y, vBottomRight.z);
	glVertex3f(vBottomRight.x, vTopLeft.y, vBottomRight.z);
	glVertex3f(vBottomRight.x, vBottomRight.y, vBottomRight.z);
	glVertex3f(vTopLeft.x, vBottomRight.y, vBottomRight.z);

	glEnd();
	glPopMatrix();
}

void CModel::SetColor(const float red, const float green, const float blue)
{
	this->red = red;
	this->green = green;
	this->blue = blue;
}

//Get the top left of the bounding box of the instance
Vector3D CModel::GetTopLeft(void)
{
	return Vector3D(vTopLeft.x, vTopLeft.y, vTopLeft.z);
}

//Get the bottom right of the bounding box of the instance
Vector3D CModel::GetBottomRight(void)
{
	return Vector3D(vBottomRight.x, vBottomRight.y, vBottomRight.z);
}